#pragma once
#include <atlstr.h>
#include <map>
#include "../ThirdPartLib/jsoncpp-src-0.5.0/include/json/json.h"

namespace CODEHELPER
{
    class CJsonUtil
    {
        typedef std::map<CString, CString> JSONVALUES;

    public:
        CJsonUtil( void );
        virtual ~CJsonUtil( void );

    public:
        BOOL   ParseJson( LPCSTR lpszJson );
        CString GetValue( LPCWSTR lpszKey );

    private:
        BOOL   ParseJsonNode( Json::Value& Node, LPCSTR pNodeName, LPCSTR lpParentNodeName );
        void   OnGetNodeValue( Json::Value& ValueNode, LPCSTR pNodeName, LPCSTR lpParentNodeName );
        BOOL   OnGetAttribute( LPCWSTR pAttr, BSTR pStringValue, LPCSTR lpParentNodeName );
        void   OnParseArray( Json::Value& arrayNode, LPCSTR pNodeName, LPCSTR lpParentNodeName );

    private:
        JSONVALUES m_values;
    };
}


